package  com.cloud.sky.txt2neo4j;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import java.util.Properties;

//import java.sql.*;

import org.neo4j.driver.v1.*;

public class FullTextIndex {

    static String url = "jdbc:neo4j:http://125.39.193.243:7474?user=neo4j,password=test123456";
    //public static Connection con;

    public String testDriver() {
       // Driver driver = GraphDatabase.driver( "bolt://localhost", AuthTokens.basic( "neo4j", "123456" ) );
        Driver driver = GraphDatabase.driver( "bolt://125.39.193.243", AuthTokens.basic( "neo4j", "test123456" ) );
        Session session = driver.session();

        session.run( "CREATE (a:Person {name:'Arthur', title:'King'})" );

        StatementResult result = session.run( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" );
        while ( result.hasNext() )
        {
            Record record = result.next();
            System.out.println( record.get( "title" ).asString() + " " + record.get("name").asString() );
        }

        session.close();
        driver.close();
        return "ok";
    }
/*
    public String testDriver1() {

        try {
            Class.forName("org.neo4j.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            System.out.println("neo4j driver not found!");
            //System.exit(1);
        }
        System.out.println("start neo4j!");
        try {

            Connection con = DriverManager.getConnection(url);
            //Properties props = new Properties();
            //props.put("user","neo4j");
            //props.put("password","test123456");

            //Connection con =  driver.connect("jdbc:neo4j:http://125.39.193.243:7474",props);

            Statement stmt = (Statement) con.createStatement();

            String query = "";

            stmt.executeQuery(query);
            ResultSet rs = stmt.getResultSet();
            System.out.println(rs);
        }
        catch(SQLException e){
            System.out.println("SQLException!");
            //System.exit(1);
        }
        System.out.println("sql done!");

        return "testDriver done!";
    }
    */

    public static void main(String[] args) {

    /*    try {
            Class.forName("org.neo4j.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            System.out.println("neo4j driver not found!");
        }
        //String password="test123456";
        //String username="neo4j";
        System.out.println("start neo4j!");
        try {
            //HttpDriver driver = new HttpDriver();
            Connection con = DriverManager.getConnection(url);
            Properties props = new Properties();
            props.put("user","neo4j");
            props.put("password","test123456");

            //Connection con =  (Connection)driver.connect("jdbc:neo4j:http://125.39.193.243:7474",props);

            Statement stmt = (Statement) con.createStatement();

            String query = "";

            stmt.executeQuery(query);
            ResultSet rs = stmt.getResultSet();
            System.out.println(rs);
            //
        }
        catch(SQLException e){
            System.out.println("SQLException!");
        }
        System.out.println("done!");
*/
    }
}

